package fyp.spedmew.connector;

import android.os.AsyncTask;
import android.util.Log;

import java.io.IOException;
import java.util.Collections;
import java.util.List;

import fyp.spedmew.backend.entity.jobEndpoint.model.Job;

/**
 * Update Job status. Param 1 is job id, param 2 is the new status
 */
public class JobUpdateStatusATask extends AsyncTask<String, Void, Boolean> {
    private static final String TAG = new Object(){}.getClass().getCanonicalName();

    @Override
    protected Boolean doInBackground(String... params) {
        Long jobId = Long.valueOf(params[0]);
        String newStatus = params[1];
        Boolean result;
        try {
            result = ApiService.getJobEndpoint().updateJobStatus(jobId, newStatus).execute().getResponse();
        } catch (IOException e) {
            result = Boolean.FALSE;
            Log.e(TAG, Log.getStackTraceString(e));
        }
        return result;
    }
}